abstract class Car(){
  var number=""
  var color=""
  var price=0
  def drive(km:Double):Unit={printf("该车还可以续航%skm\n",km)}
  def stop():Unit={println("电池续航不够，无法继续行驶，即将停车")}
  def oil():Unit={println("正在加油")}
}
class ElectricCar() extends Car(){
  var km=0.0
  def info():Unit={printf("这是一辆颜色为%s,车牌号为%s,价格为%s万元的车\n",color,number,price)}
  def charge():Unit={println("该车电池续航里程不足,需要给车充电")}
  override def drive(lkm:Double):Unit={
    if(km>=lkm){println("该车电池续航里程足够，可以使用")}
    else{charge()}
  }
}

object MyCar{
  def main(args:Array[String]){
    val mycar=new ElectricCar()
    mycar.number="赣JD12730"
    mycar.color="紫色"
    mycar.price=10
    mycar.km=405.2
    mycar.info()
    mycar.drive(400.0)
  }
}
